Fixed costaveraging function for national so works