all the code! it nearly all works!