Refactor admin.js