Consider using function to check type of variable

I think we should we function to check type of variable like underscore or lodash to make it more flexible or easier to test