fixed code as per code review comments