refactor guard patterns