Simple algorithm fix