some refactoring, now I feel better