I prefer this AppResolver method...
Credit Romanbb
Fixed line errors...