Using now a structure for dealing with header. Added check for correct boundaries.