Collision detection sketch running extremely slow


I’m working on a sketch drawing circles and squares that slowly fall to the bottom of the window and begin to stack. I first got things to work using matter.js here:

and now am trying to get the same effect without it:

I am now running into a problem with the sketch running extremely slow/glitchy after drawing even just one or two shapes. I think this may have to do with the shapes being added in the draw() function every X frame and then checking for collisions, although I am not sure…

I would greatly appreciate any help. Thank you in advance!