refactoring (all in one)