Added check for nil apps