cleaned up code and comments