Fixed mistake in error handling