refactor'd to be a bit easier to interact with for an http api