updated to use indexed array