revised to handle new button logic