Sort of got the thing working