refactored some code related to active_admin