Improved functionality everytime a state changes