Duh! the suffering caused by copy and pasting lines... line 45 and line 52 should be roots[1] NOT [0]