i've started a very crude version here