refactor using dynamic binding