reorganized and more documented