fixed issue that deleted the non-canvas sections, refactored code