properly calculating cost