add comments and refactor variables