now also catch index out of range error
add new line at beginning of main()