Added the code for fetching average spent