Bug fix with variables as cost