updated logic for button states