Made changes to the code to increase modularity and prepare for drawing on the canvas