cleaned and documented code