fix nonetype error and fix #310