add offsets calculation