cleaned and commented