added metrics and logging