refactor and comment