Refactor dashboard js