Attached a function to the buttons