added authentication handling.