corrected algorithm counting islands