big refactor, a lot more modular