fixed code to match demo