safeButton refactor