going through major refactoring of the code to make it easier to use and clearer