correct cost computation