I hacked it together, needs a lot of edits

but it works