refactor massively