refactor admin code