6. added exit functionality