Modifying the handleFiles function