cleaned and commented a bit