Added the implementation of distinguishing ref and value