fixed the bug that uses the inverserd logic by mistake.