added returning of offset for optional header