Updated with some feedback from code review