Added some errorchecking. Not getting proper results from analyzedata, so not quite working
Old commit