Added option for returning first or all results