add sanity checking for type