Revised code as per code review v1.1