s4/getncchanges: Move the code that collects objects into separate function