make category key work if the app_id is null

This is a small change to the O(N*N) patch to deal with a null app_id