updated logic to fix secure apps while also fixing #3