finish the iap function.