some refactoring to explore extensibility