change raw queries to ruby style 'where' clauses