Refactored the code on the admin page