Add missing check for empty list