Revised code as per code review v1.0