changed header stucts to programmatically calculating length