fix crash on apply button clicked