performance boost in getFrameClosest