Factorise some code to simplify it and fix a usage of out of scope variables
Factorise some code to simplify it and fix a usage of out of scope variables

en90/pkg,khorben/pkg,khorben/pkg,en90/pkg,khorben/pkg