refactory admin code.