reviewed and cleaned the code