cleaned up, added comments