frame and last frame refactoring