refactored code, added comments, and completed reflection