refactored functions
fixed button