made some algorithms more efficient