finally fixed the bug