fixed buttons and added code efficiency