refactor and commenting