compute offset.