Correct Some of the Errors and remove unused variables