flatten_list.py : Refactored