add middleware, update some codes