refactor closing