check the type of value before convert