cleaned the code and comments added