some refactoring/testing