fixed frame number computation bug