refactored app.js. added pan and reload functionality