some refactoring, needs more