Refactor entirely