Fixed not calling a function in an if statement