added empty() to sum