Works for all test cases. Need to clean up. Some issues with the naming of variables
Cleaned unused variables