Refactoring: immediate function pattern