Clean up repetetive error handling with goto