Fixed NoneType error