Added resort to api if not found in db functionality