Correct implementation, with refs