Added 'end' to if statement