reorganized, cleaned up errors