WIP: code refactoring