improve error handling to avoid the eternal spinning ball