Refactored the arrive code