refactor query on persist