I think you could safely get rid of Doc and just use the call to cb_context:doc/1 here. Seems unnecessary to bind a variable to only use once. Not crucial though