added cost.R