fixed the bug with offsets