Moved button functions into document ready function