Ported to new algorithm