added more logic in as well as new documentation

algorithm is complicated but good (as in fast it might not even work)
ok

this is blueJ fault