added some changes in authenticate functionality