Organize code and add comments