modified algorithm to calculate aces