added type cast consistency checks