refactor  code