fixed infinite loop bug in budget calculation