Correctly return err and count