replaced conditionals by polymorphism