refactored app.js and finished authorization