added safeApply