added basic error handling on instantiating object