refactor of code