some refactoring into bin, needs more