Fix bug 'can not call method on of null'