refactor the code,thanks.