small bug fix with exit