refactoring source code to prepare better interface