Fixed a bug in the code

Playing with if blocks without curly brackets is a dangerous game...