simplify compute_offset implementation