Added state logic to buttons