Fixes bug with avg calculation