Added base script
More robust control flow