This is as far as I can refactor atm i think