Added initFigure as a function
Changed hardcoded parameters into variables defined from the start