Refactored button stuff into own functions