abstracted the code to allow for dependency inversion