implemented new algorithm, added acceptance tests