added errorhandling to authorization