add type check before get/set value