refactor flag controller action.