made some actual code
First draft - buggy
Functional first draft