doing some refactoring, a little broken...