Simplify absorption algorithm using sets