Refactored buttons and added listeners