Changed colMode to statsMode to handle rowMode as well. Included avgDifFromMode function