Improved logic so it works with Allura ITS