basic impl of algorithm implemented; not tested