rearranged scripts sequence and add the api call