adding tuple list flattening code