added a check for nil applications