updated based on code review