completed writing fast version functions.  needs debugging