moves encode and decode into primary header