added findBestShift fn, fixed bug in findBestShift