Rewrite to use index