Added calculating cost metric