added functionality to check class instances for type correctness