If you look at line 1732 you can see that we use the variable $avg_unit instead of hardcoding ' B'. You should look at whether we can re-use the $avg_unit or need another means to determine the proper units.