Main script updated