some refactoring and measuring time