refactored type declaration parsing