compiles and runs, but gains are done wrongly, having nan's everywhere apart from first and last
wip