Changed to dynamic polymorphism.

Changed to dynamic polymorphism for more flexibility.