correct cast bug and update global parameters