code added, for smoothening, taking avg for now.