function created to calc damage cost