You mustn’t check the timer variable against NULL but against null, that was correct in your 1st version.
See also [SOLVED] Unexpected results with Val math operators - #5 by rlkoshak and [SOLVED] NULL | UNDEF | null | uninitialized - #4 by rlkoshak