this is so much a draft, finally got the codes sorted out