made button logic more readable