small refactor to clarify and throw exception when there is a problem
instead of failing silently.