Fixed bugs and now it's working