fixed off by one error for frames