more elegant error handling