Fixing an issue with cost computation