Refactor create-fun