Move pattern definition outside of if/else block.