You should always use curly brackets{} after if statements, even if they only contain one line.

Since your if statement does not have curly brackets, it is only applied to the very next line,...