Replaced if/else with pattern match when creating file list