fix cast issues