refactored metrics api