fixed the bug reported by Jim