Refactor to use dynamic method calling substantialy reducing code length