refactor, reorganize, and replace fake 'select' to reduce CPU load