fixing bug reported by David