implement algorithm, doesn't know if its working yet