• added #defines
• formatting
• changed if else flow (should be semantically the same)