cleaned up the code to remove unused variables