exit functionality fixed