simplified the frame calculation logic