Updated smart query to look at documentState