refactor and cleaning