modified rancost function