updated to work in both the old or new toolchain