array program now works correctly