Fix for bad casting