Added function to check permissions