80% of logic, i have done a few tests, i surprise that my algorithm works like charm :) need to test more later when i have a simple GUI