modified to calurate kind of getFrameAt when to is not exist.