replace conditionals with polymorphism