Changed a few lines of code and now it works!