Rhys: fixing bug when averaging values with null values