reorganized and corrected some errors