some npe bug fix