refactoring to gain flexibility