change dynamic dispatch to compile-time dispatch