code refactor for admin dashbard