Redesign the SOPT setup code with design pattern