fixed code based on code review comments