cleaning up code and adding some comments