Changed ref function