Fixed error with casting (I hope)