Refacted embeded search into its own method.