Updated code to calculate budget automatically