added authentication logic