cleaned code and refined documentation