some refactoring into more helpers