refactor codes
option
max, min, sum
a bit refactor