fixed the bug totally