Added some error handling.
throwing is not good!