Add Authorization Function and bug fix

Add Authorization Function and bug fix