FIx issues and bugs , use shuf in place of sort head logic, fix order of vars