major refactoring/reworking