added authentication middleware