Lots of bugs but it finally works