add logic, but there is a bug: the high CPU