memory leak caused by events .on() fixed by calling .cancel() at the end