updated logic to support applications