refactored old button logic