Broke main actions into separate functions