edited code based on code review comments