corrected button logic