removed use of rewrite which does not always work well.