Correct the offset calculation