Fixed the weird type cast problem