refactor namedqueries