Added sanity check to avoid NPE when called for empty maps