better type parsing, actually works properly