Changed the state to if statement