Refactor dashboard.js