simplify offset calculation