added case check if the ArrayList was null