Updated the code after review.