Cleaning up code with dynamic method calling

Cleaning up code with dynamic method calling