Added a check if a button is clicked