deal with NoneType error