comments, tweaks. found a bug with avg() logic