Use empty() instead of size() for emptiness check.