Reworked the standard algorithm