corrected with code review comments