refactor and comments in code