Refactored the Button Code