Addresses #6 - wrapped code in abstracted function