update

Cleaned the code; reorganized some clauses