In what ways can this function fail? Should failure change the result and whether the counter is incremented?