Reversed ordering of algorithm to increase speed