add conditional check for clear