Refactor Update #3

Reduce the code and pulled out common boiler plate code.