fixed rewriting bug (#18)