algorithm now works
ui is fixed