added message middleware