this should probably be more resilient to the case where no app matches.