exit logic added