working monotone chain algo

need alot of refactoring tho and clean up.