Refactor

Finished the refactor