Added logic for upkeep calculations.