fix bug in algoritm
added button - invert selection