Fixed bug from rewrite