Move createWord function to local scope