updated code to calculate budget automatically