clean up SQL code a bit (temp index out of schema)