added code to check authentication