Function groupFiles