Also, the function appears almost duplicated; write a function to generate this anonymous function which is parameterized on the values needed for the pb_socket:get.