Wrapped the actions correctly in functions