This fixes #7822.  It now calculates the offset.