return list instead of writing to the file