add a function and fix some wrong