Cleaned up code and added quit