parially rewritten