refactor create activities code