cleaned and commented some code