refactored clear function. removed redudant commands