Fixed circular mean code after testing.