use more pattern match
less defensive, more intentional
use pattern match in function head to remove the stupid logic, make
code much compact.