move admin code to model