Search algorithm now shared between worker and main script.