altered code to be driven by additional array