Fixed bugs and created a working version