Add problem #127
Some optimization for #127