added fix for the "last frame emtpy" problem.