Separating the code to publisher and subscriber