Added deleted check to agent view queries.