modify array loop routine