this still needs a refactor.