implemented new function and metrics; bug fixes