Fixed an issue with the if statement ending too early.