final algo
finishing touches
merged