Change authorization to work with promise instead of cb
Tidy up code