Initial attempt to add error handling