finally found the bug