add ability to set default value.

also update some logic.