Added more options, added code to flatten array if necessary