Edited 'insert' and 'remove' functions