moved the quit function to the bottom for better readability