wrote code to remove/close resources on over-written indexes