Refactored code, fixed on-click action.