Refactored - temp gets updated whenever a button is clicked