function for all actions.