Changes for Jess and fixed the sorting of varibles