Refactored create family JS code.