fix bug of indexing the frame