Null pointer fix for search