fixed residual. it is REFACTORING time