initial commit

this code is fugly, but it somehow magically works