Made this a little DRYer by using a constructor

I edited this directly in GitHub, so you might want to test to see if it still works. :)