dynamically calculates range average