fix counting bug in backward frame length