replace conditions with polymorphy