Refactor Main Program