Implementing functions: sum, count, avg