some refactoring.