a little cleanup and reduce the trim calls

Cleaned up some jslint/jshint type errors.
Also noticed that we were re-trimming the metric type each time so moved that to a variable.