Refactor the code to make it more elegant and optimized (especially for the core algorithm).
Refactor the code to make it more elegant and optimized (especially for the core algorithm).