What is this doing? Please use basic line comments for non-obvious logic