correct error handling so that it at least wont explode