ADD detect middleware function length