fix arrival function