Fixed NPE in filtered query