Putting the bug fix into the correct part of the if statement.