Fix incorrect pointer calculation