added algorith and half-done impl