efficiency function. works pretty well, fixed some bugs, commented stuff out. it's a work in progress goddamnit