Rewrite for performance