middleware scripts