modified the Value class to implement double dispatch pattern.