I wonder if this code would be simpler if we exploit the Grid.getApps() results.