improved api directive injection