refactor safety ensurance