heavy refactor