Guillaumes code integrated into NF, please check if that makes sense