rewriting and testing