more improvements thanks to christophe's review