budgeting alrotihms partially refactored and also redesigned