update code to use the type attribute instead of _type