preconditions, some refactoring