slightly adjust error handling