brought main script over