added saftly exiting program