improve errormetrics, add global variables