cleaned up some code for the risearch queries