metrics implementation (first version, needs to rethink)