Fix 52843321: Refactored condition into a def and added check to not let new app exceed quota