Modified code as per review.