fix NoneType len bug