changed code to facilitate Job Arrays