fixes #18; throw exception on invalid input