pass in getElements function other than elements themselves