metrics refactoring
Updates to API query and refactoring