fix a Nonetype error