Chg: cleaned a bit the code