more robust count error handling