fixed a bug in type safety.