Improvements to button function