Used the sweet closure method for defining variables for the element.