Added create_button function to get rid of repeated logic. Also changed code to match PEP8 standard