Refactor error handling, limit retries per cas call