refactored some names, added some comments