squash npe and really fix #663