Change asInstanceOf to match for type checks