Updated math for frame calculation