moved display_list function and cleaned up code