refactored some name conventions and add comments to describe functions