fix references
made the loop faster for the metrics
eliminate some empty line