fix bug spotted by Ivo with solution to #612