Missing an 'end' for the above 'if' block