move subscribe / fetch code into its own file