work in progress, still missing the end and some more work