Hacked together an initial implementation