made admin.js more reusable and functional