refactored action handling