Refactores authorize
Updated authorize script