Removed several errors in the code