fix nil/empty issue in search