modify model code for new api.