Repair and add first algorithm fo main function
repair