fix some err, add a new function