improve speed for compose middleware