fix nonetype error