refer other's elegant algorithm, to summary