Adding function to change states.