changed calcavr function