add pub/sub support
fix bug