Adding authentication check code