some refactoring...