added buffer to print avg values & cleanup