updated main script to handle updates and ending