refactor the coding