revised parts slightly