Tim,

I wonder why it should work anyway (there is only 1 endif for several ifs)

Well if this is all the code it evaluates before failing , but still this is a bad piece of code

You might consider Jens' snippet above to start with
_________________________