fixed problems in list() and a helper function