Added check for __len__