add correct error handling