added checks for the buttons