added quit logic