working on refactoring and adding comments to all functions and properties