working on safe type casting