handle situations where list is empty or null