added some middleware fn