working but need refactor. A lot of.