Refactors to make testing easier and allows for passing of arguments to functions