added more auth middleware code