removed volatile hash and refactored metric_handler for readability