adding cost generation function