Refines creategroup JS logic.