add safe_count class