basic algo done, but not yet tested