general algorithim
v0.1