close element refactored