#4 add middleware support