Fix for forward search. Refactoring.