move clear logic from load to clear function