fixed nan problem