changed code as per code review