Add toType() method