incorporate #224 thanks @ccarruitero