Move code to admin controller