fix issue #77 bad logic