Tidied up the button code