Success... ripped off version working, just need to add a nicer interface etc around it