add type check in subscribe