adding code for exit