nan problem but result still wrong