main function: changed the order of hadvppm function