fixed bug found by Benoit Leveau