Pattern matching with look-ahead to handle overlaps fix from previous commit