reworked offset calculating process

fixes # 58
fixes # 53