cleaned and comments added