functional publish/subscriber code