Updated the code. Please check.