Fixing the followed algorithm