refactor how errors are handled

@brishin, this is a lot cleaner