clean up code, adding comments