modifying cap script per Vaughn's suggestions