Refactore, remove unnecessary hiera call and add type check