fix #2434 - wrong calculation of offset