added a crude but effective outlier removal function