bug fixes with ave()