updated for rewrite