heavy refactorings