Modified search function to ccheck if the processed spectrum is nil