refractor remove function