added publish and subscribe functions