Fix nonetype conversion error