Performance optimization

No need for backtracking. Haven't benchmarked if it's actually faster.