first complete version - not working
fixed some bugs and added verbosity option. Still wrong result for test cases