More refactor of code