cleaned up code and removed some comments