some refactoring needed later