Solve bug returning invalid reference.