averaging works! changed tmp vals from unsigned chars to ints.