mistake in changing to function