Fix error in type casting