Fixed casting problem