corrected insert and removal related functions