[refactor] refactoring the internals -- not happy with it yet