calculate_total code refactored and corrected for Aces