added authentication and valiation logic