bug fix when removing records