bug fix in getFrameClosest