finishes refactoring of coalescence function