move metrics code