reordering js calls