refactored clearing utils