added option to return an object instead of array, so the server can return a total matches property