fix bad casting