algorith updated to v 3