refactor and comments