fixed the bug reported by Dave