changed GetVarOffset api to require type as argument