Fixed double casting problem