comments and code refactor