Fix bug pointed out by xmj in #1