Latest updated code with updated review comments.