Improve admin main function