cleaned code and commented