restructure signal sel code