Fixed bug with file modification
new utility functions expand_list & flatten_list