@xiangli-cmu 
type() is not allowed. I used ptype() instead.