Generification of US-am script. Nearly ready to turn into a function!