fixme
major refactoring