Rework the logic to get file