Fixed NPE for index queries