fix bug with exit