add script for tests
update algorithm