Refeactoring of packaging and finish the main program