big refactoring, unstable