timing for patterns works
some refactorings