added zero length check