Improve remove function