Added algorithm for detecting how much each user has spent in total.