refactorize code for get_action_permalink