Updated + fixed some errors in the code