some refactoring because DRY