Refactor 'remove element'.