basic error handling when no more IDs can be retrieved from the database